// 模拟后端 API 服务
export const loginApi = (username, password) => {
  return new Promise((resolve, reject) => {
    setTimeout(() => {
      // 模拟验证
      if (username === 'admin' && password === 'admin') {
        resolve({
          success: true,
          data: {
            id: 1,
            username: username,
            name: '系统管理员',
            role: 'admin',
            token: 'mock-jwt-token-' + Math.random().toString(36).substring(2)
          }
        });
      } else {
        reject({ 
          success: false, 
          message: '用户名或密码错误' 
        });
      }
    }, 1000); // 延迟1秒，模拟网络请求
  });
};

export const getUserInfo = (token) => {
  return new Promise((resolve) => {
    setTimeout(() => {
      resolve({
        success: true,
        data: {
          id: 1,
          username: 'admin',
          name: '系统管理员',
          role: 'admin',
          avatar: null,
        }
      });
    }, 500);
  });
}; 